<?php

/*
 * To change this template use Tools | Templates.
 */
namespace Versal\AdminBundle\Validator\Constraints;

use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;

class ContainsAlphanumericValidator extends ConstraintValidator
{
    public function validate($value, Constraint $constraint)
    {
        if (!preg_match('/^[a-zA-Za0-9]+$/', $value)) {
            $this->context->addViolation( $constraint->message, array('%string%' => $value) );
        }
    }
}